package formbean;

import java.util.ArrayList;
import java.util.List;

import org.mybeans.form.FormBean;

public class ReplyForm extends FormBean{
	private String replyMessage;
	private String userId;
	private String status;
	private String button;
	
	public String getReplyMessage() {
		return replyMessage;
	}
	public void setReplyMessage(String s) {
		this.replyMessage = s.trim();
	}
	public String getUserId() {
		return userId;
	}
	public void setUserId(String s) {
		this.userId = s;
	}
	public String getButton() {
		return button;
	}
	public void setButton(String button) {
		this.button = button.trim();
	}
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status.trim();
	}
	
	
	public List<String> getValidationErrors() {
		List<String> errors = new ArrayList<String>();

		if (replyMessage == null || replyMessage.length() == 0) {
			errors.add("Message is required");
		}
		
		if (status == null || status.length() == 0) {
			errors.add("Marker is required");
		}
		
		if (replyMessage.matches(".*[<>\"].*")) {
			errors.add("Message may not contain angle brackets or quotes");
		}
		
		if (status.matches(".*[<>\"].*")) {
			errors.add("Marker may not contain angle brackets or quotes");
		}
		
		
		return errors;
	}
	
}
